import http from "@/utils/http";
import type {
  TodoListParams,
  TodoTypeNumberParams,
  numbersType,
  TaskApplyDelayParams,
  TaskCrmCompleteParams,
  AddTaskParams,
  TaskApplyDelayResultParams,
  ToDoNextTaskRes
} from "./type";

/**
 * 查询所有用户任务
 */
export const allTaskList = () => {
  return http.get("/process/task/userTaskList");
};

/**
 * 获取所有用户发起的流程
 */
export const allMySubmittedList = (params: any) => {
  return http.get("/process/instance/mySubmitted", params);
};

/**
 * 获取待办事项列表
 * @param data 查询参数
 */
export const getTodoList = (data: TodoListParams) => {
  return http.get("/crm/workbench/pageList", data);
};

/**
 * 待办事项类型数量
 */
export const getTodoTypeCount = (data: TodoTypeNumberParams) => {
  return http.get<numbersType>("/crm/workbench/number", data);
};

/**
 * 办理CRM流程任务
 * @param { string } commTaskId -任务ID
 * @param { TaskCrmCompleteParams } data
 */
export const taskCrmComplete = (commTaskId: string, data: TaskCrmCompleteParams) => {
  return http.post(`/crm/workbench/transact/${commTaskId}`, data);
};

/**
 * 客户基本信息 + 跟进记录
 */
export const clientInfoAndFollow = (customerId: string) => {
  return http.get(`/crm/info/getInfoPenetration/${customerId}`);
};

/**
 * 租户自定义——根据字典类型获取字典列表
 * 跟进类型
 */
export const dictDataList = (params: { dictType: string }) => {
  return http.get("/crm/system/getDictDataList", params);
};

/**
 * 工作台待办添加跟进记录
 */
export const addTrack = (data: AddTaskParams) => {
  return http.post("/crm/track/add", data);
};

// export const addTrack = ( commTaskId:string,data:AddTaskParams ) => {
//     return http.post(`/crm/workbench/transact/delayFollUp/${commTaskId}`,data);
// };

/**
 * 根据日历查询待办任务
 */
export const getTodoListByCalendar = (date: string, isOut: boolean, status: number) => {
  return http.get("/crm/workbench/calendar", { date, isOut, status });
};


/**
 * 跟进客户id查询客户跟进进度
 */
export const trackTask = (customerId: string) => {
  return http.get(`crm/build/task/TrackTask/${customerId}`);
};

/**
 * 待办获取指派时间的下个任务
 */
export const toDoNextTask = (stageTaskId: string) => {
  return http.get<ToDoNextTaskRes[]>(`crm/build/task/toDoNextTask/${stageTaskId}`);
};

/**
 * 获取未分配数量
 */
export const unAssignedCustomerTotal =()=> {
  return http.get(`/crm/info/statisticsToBeAllocated`);
}
/**
 * 调整计划详情
 * stageTaskId 任务id
 */
export const adjustPlanDetail = (stageTaskId: string) => {
  return http.get(`/crm/build/plan/getAdjustTaskPlan/${stageTaskId}`);
};
/**
 * 获取调整后的时间
 */
export const changeTime = (stageTaskId: string, params: any) => {
  return http.get(`/crm/build/plan/getBuildChangeTime/${stageTaskId}`,params);
};
/**
 *提交调整时间
 */
export const submitAdjustTime = (data:any) => {
  return http.post(
    `/crm/build/plan/addAdjustTaskPlan`, data
  );
};
/**
 * 根据角色id筛选人员
 */

export const memberByRoleId = (params:any) => {
  return http.get(`/crm/build/plan/selectionRoleIdUserName`, params);
};

